﻿@{
    ViewBag.Title = "送货单列表";
    Layout = "~/Views/Shared/_LayoutList.cshtml"; 
}
@(       
 Html.DWZGridFor<Resto.CostControl.Core.DishDelivery>()
        .Title("送货单列表")
    .Action(@Url.Action("Index"))
    .Columns(col =>
    {
        col.Bind(e => e.Id).IsKey();
        //col.Bind(e => e.Code).Width(80).AsQuery().Align(FlexiGridAlign.Left);
        col.Bind(e => e.Date).Width(70).DateFormat("yyyy-MM-dd");
        col.Bind(e => e.SiteID).Width(80).EnumKey("ProjectSite");
        col.Bind(e => e.Address).Width(140).Align(FlexiGridAlign.Left);
        col.Bind(e => e.State).Width(40).EnumKey("DishState");
        //col.Bind(e => e.ItemDesc).Width("auto").Align(FlexiGridAlign.Left);
        col.Bind(e => e.UpdateUser).Width(60);
        col.Bind(e => e.UpdateDate).Width(70).DateFormat("yyyy-MM-dd");
        col.Bind(e => e.Id, "操作", 180).Sortable(false)
        .Template(Url.GridLink("accept", "送货", "MaterialDelivery('${Id}')")
            + Url.EditLinkTwo(Url.Action("Edit"), "编辑送货单")
            + Url.DeleteLink("Delete", "${Date}"));
    })
    .Buttons(btn =>
    {
        btn.Bind("Add", "新建送货单", FlexiGridButtonType.Add).Action(@Url.Action("Edit")).OnPress("AddNewTwo");
    })
)
<script type="text/javascript">
    function MaterialDelivery(Id) {
        if (confirm("你确定要送货?")) {
            showLoadingMsg("正在送货...", { left: 300, top: 2 })
            $.post('@Url.Action("MaterialDelivery")', { id: Id },
                     function (data) {
                         if (data.IsSuccess) {
                             refreshGrid();
                             showLoadingMsg("送货成功", { left: 300, top: 2 }, true, 3000);
                         }
                         else {
                             hideLoadingMsg();
                             showErrorTip(data.Msg, { left: 300, top: 2 }, true, 5000);
                         }
                     },
                "json"
                );
        }

    }

</script>
